#include "swagme.h"
#include "Swag.h"

const int Swag::FrameCount = 2;

Swag::Swag(Sprite* ps, int x, int y, int _pts)
  : FrameCounter(0),
    mpSprite(ps), posX(x), posY(y), mPoints(_pts) {
  if(!mpSprite) { cerr << "Swag initialized with NULL sprite" << endl; exit(500); }
  FrameCounter = random(0,32*mpSprite->getNumFrames());
}
    
Swag::Swag(Sprite* ps, int _pts)
: FrameCounter(0),
  mpSprite(ps), posX(0), posY(0), mPoints(_pts) {
  if(!mpSprite) { cerr << "Swag initialized with NULL sprite" << endl; exit(500); }
  FrameCounter = random(0,32*mpSprite->getNumFrames());
}

Swag::Swag(int _pts)
: FrameCounter(0),
  mpSprite(NULL), posX(0), posY(0), mPoints(_pts) {
}

int Swag::Draw(SDL_Surface *dst) {
  int r, frameNum ;

  if (++FrameCounter >= 32*mpSprite->getNumFrames()) FrameCounter = 0;
  frameNum = FrameCounter /32; // TODO: this is an ugly hack, need a proper central animation timer

  // mpSwagPenSprite->Draw(0, ((penFrame/32)%2),mpDisplay->getScreen(), 78+MAP_POS_X, 78+MAP_POS_Y);

  // cout << "x " << posX << " y " << posY << endl;
  return mpSprite->Draw(0, frameNum,dst, posX+MAP_POS_X, posY+MAP_POS_Y);
}

Swag::~Swag() {
}
